/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cifar10.featureextraction;

import java.awt.image.BufferedImage;
import java.util.List;

/**
 *
 * @author mwh
 */
public class Combiner extends AbstractFixedSizeFeatureExractor implements FixedSizeFeatureExtractor{

    List<FixedSizeFeatureExtractor> feList;

    public Combiner(List<FixedSizeFeatureExtractor> feList) {

        StringBuilder nameSb = new StringBuilder();
        int tsize = 0;
        for (FixedSizeFeatureExtractor fe : feList) {
            tsize += fe.getSize();
            nameSb.append(fe.getName()).append(".");
        }
        nameSb.deleteCharAt(nameSb.length() - 1);
        name = nameSb.toString();
        size = tsize;

        featuresNames = new String[size];
        int index = 0;
        for (FixedSizeFeatureExtractor fe : feList) {

            for (String featName : fe.getFeatureNames()) {
                featuresNames[index] = featName;
                index++;
            }
        }
        this.feList = feList;
    }

    @Override
    public double[] getValues(BufferedImage image) {
        double[] values = new double[size];
        int index = 0;
        for (FixedSizeFeatureExtractor fe : feList) {

            for (double fval : fe.getValues(image)) {
                values[index] = fval;
                index++;
            }
        }
        return values;
    }

}
